{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "36b35ceb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hey Python!\n"
     ]
    }
   ],
   "source": [
    "print('hey Python!')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "79170322",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6b221f22",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ed4a5123",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "array() missing required argument 'object' (pos 0)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[4], line 2\u001b[0m\n\u001b[0;32m      1\u001b[0m np\u001b[38;5;241m.\u001b[39marray([\u001b[38;5;241m1\u001b[39m,\u001b[38;5;241m2\u001b[39m,\u001b[38;5;241m3\u001b[39m,\u001b[38;5;241m4\u001b[39m,\u001b[38;5;241m5\u001b[39m])\n\u001b[1;32m----> 2\u001b[0m np\u001b[38;5;241m.\u001b[39marray()\n",
      "\u001b[1;31mTypeError\u001b[0m: array() missing required argument 'object' (pos 0)"
     ]
    }
   ],
   "source": [
    "np.array([1,2,3,4,5])\n",
    "np.array()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d1766fe6",
   "metadata": {},
   "outputs": [],
   "source": [
    "np.array([[1,2,3],[4,5,6]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d7068554",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3580af38",
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.imread('https://www.baidu.com/img/PCfb_5bf082d29588c07f842ccde3f97243ea.png')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dabced83",
   "metadata": {},
   "outputs": [],
   "source": [
    "img_arr = plt.imread('./bd.png')\n",
    "plt.imshow(img_arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0939ec38",
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.imshow(img_arr - 0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d443b6b5",
   "metadata": {},
   "outputs": [],
   "source": [
    "img_arr.ndim\n",
    "img_arr.shape\n",
    "img_arr.size\n",
    "img_arr.dtype"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a766cbd9",
   "metadata": {},
   "outputs": [],
   "source": [
    "np.linspace(1,100,num=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b5550913",
   "metadata": {},
   "outputs": [],
   "source": [
    "type(img_arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b5976718",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr = np.random.randint(60,120,size=(6,8))\n",
    "arr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ab933fab",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr[1]\n",
    "for i in range(0,len(arr)):\n",
    "    print(arr[i][0])\n",
    "arr[0:5][:1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4b0500a8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4f4c9b5f",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "np.arange(0,100,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce4eb43a",
   "metadata": {},
   "source": [
    "- 随机原理\n",
    "    - 随机因子： 标识的是一个无时无刻都在变化的数值\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c50bc9dd",
   "metadata": {},
   "outputs": [],
   "source": [
    "np.random.seed(10)\n",
    "np.random.randint(0,100,size=(4,5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5b562bab",
   "metadata": {},
   "outputs": [],
   "source": [
    "np.random.random(size=(4,5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "69bff762",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "337f66e8",
   "metadata": {},
   "outputs": [],
   "source": [
    " arr[0:2]      "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4353a41b",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr[:,0:2] #逗号机制"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "72fa7f58",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(arr[0:2,0:2])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a36b5ff2",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(\"原数据\",arr)\n",
    "print(\"转置后：\" ,arr.T)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b6bd432a",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "arr[::-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a549cd8b",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr[:,::-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9fd0d0dd",
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.imshow(img_arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "10c4e393",
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.imshow(img_arr[:,:,::-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24a4a81b",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b40529b",
   "metadata": {},
   "outputs": [],
   "source": [
    " arr_1 = arr.reshape((48,))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c895e2b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr_1.reshape((48,1))\n",
    "arr_1.reshape((-1,4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "90c8f58c",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "943d446a",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(arr)\n",
    "np.concatenate((arr,arr),axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d951123e",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr_3 = np.concatenate((img_arr,img_arr,img_arr),axis = 1)\n",
    "arr_9 = np.concatenate((arr_3,arr_3,arr_3),axis=0)\n",
    "plt.imshow(arr_9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e0054205",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(arr)\n",
    "arr.sum(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "081b4e66",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr.sort(axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f250a290",
   "metadata": {},
   "outputs": [],
   "source": [
    "arr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7691a962",
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.imshow(img_arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ad65203b",
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.imshow(img_arr[50:100,50:150])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c164ec44",
   "metadata": {},
   "outputs": [],
   "source": [
    "np.array()"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "无",
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
